import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

const routes = [{
  path: "/",
  name: "main",
  component: () => import("../views/Main.vue"),
  children: [{
    path: "/",
    name: "home",
    component: () => import("../views/home/Home.vue")
  }, {
    path: "/user",
    name: "user",
    component: () => import("../views/user/User.vue")
  }, {
    path: "/swagger",
    name: "swagger",
    component: () => import("../views/system/Swagger.vue")
  }, {
    path: "/sql",
    name: "sql",
    component: () => import("../views/system/SqlPanel.vue")
  }]
}, ];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes
});

const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

export default router;